package com.littcore.saap.system.web;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.ModelAndView;

import com.littcore.common.Utility;
import com.littcore.dao.page.IPageList;
import com.littcore.dao.ql.PageParam;
import com.littcore.exception.NotLoginException;
import com.littcore.saap.core.web.util.LoginUtils;
import com.littcore.saap.system.service.IUserOpLogService;
import com.littcore.web.mvc.action.BaseController;
import com.littcore.web.util.WebUtils;

@Controller
public class UserOpLogController extends BaseController{
	
	@Resource
	private IUserOpLogService logService;
	
	  @RequestMapping 
	  public ModelAndView getLogs(WebRequest request) throws NotLoginException
	  { 
	   
	            
	    String moduleCode = request.getParameter("moduleCode");
	    Integer recordId = Utility.parseInt(request.getParameter("recordId"), null);
	    
	    //package the params
	    PageParam pageParam = WebUtils.getPageParam(request);
	    pageParam.addCond("tenantId", LoginUtils.getTenantId());
	    pageParam.addCond("moduleCode", moduleCode);  
	    pageParam.addCond("recordId", recordId);  
	    pageParam.addCond("isDeleted", false);  
	    pageParam.addSort("opDatetime", "desc");
	    //Get page result
	    IPageList pageList =logService.findPage(pageParam);   
	    
	    return new ModelAndView("jsonView").addObject("userOpLogs", pageList.getRsList()); 
	  
	  } 

}
